use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::IchimokuCloud

///
///  参见[IKC](https://en.wikipedia.org/wiki/Ichimoku_Kink%C5%8D_Hy%C5%8D)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct IKC {
    ///  2 signals
    ///  When Tenkan Sen crosses Kijun Sen upwards and source value is greater than both Senkou Span A and B and when Senkou Span A is greater than Senkou Span B, returns full buy signal.
    /// When Tenkan Sen crosses Kijun Sen downwards and source value is lower than both Senkou Span A and B and when Senkou Span A is lower than Senkou Span B, returns full sell signal.
    pub signal0: Option<IndicatorActionWrap>,
    ///  
    ///  When source value crosses Kijun Sen upwards and source value is greater than both Senkou Span A and B and when Senkou Span A is greater than Senkou Span B, returns full buy signal.
    /// When source value crosses Kijun Sen downwards and source value is lower than both Senkou Span A and B and when Senkou Span A is lower than Senkou Span B, returns full sell signal.
    pub signal1: Option<IndicatorActionWrap>,

    /// 4 values
    /// Tenkan Sen
    pub tenkan: ValueType,

    /// Kijun Sen
    pub kijun: ValueType,

    /// Senkou Span A
    pub spana: ValueType,

    /// Senkou Span B
    /// Range of all the values is the same as the range of the source values.
    pub spanb: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct IKCConfig {
    ///l1: PeriodType
    ///Tenkan Sen period. Default is 9.
    ///
    ///Range in [1; l2).
    ///
    pub l1: PeriodType,
    ///l2: PeriodType
    ///Kijun Sen period. Default is 26.
    ///
    ///Range in (l1; l3).
    pub l2: PeriodType,
    /// l3: PeriodType
    /// Senkou Span B period. Default is 52.
    ///
    /// Range in (l2; PeriodType::MAX).
    pub l3: PeriodType,

    /// m: PeriodType
    /// Move Senkou Span A and B forward by this period. Default is 26.
    ///
    /// Range in [1; PeriodType::MAX).
    ///
    pub m: PeriodType,
    // source: Source
    // Source type. Default is Close.
}

impl Default for IKCConfig {
    fn default() -> Self {
        Self {
            l1: 9,
            l2: 26,
            l3: 52,
            m: 26,
            //source: Source::TP,
        }
    }
}
